package com.yidiandao.business.ui.widget.listview.displaylistitem;

import android.content.Context;

import com.yidiandao.business.data.bean.Discount;
import com.yidiandao.business.data.bean.FavourableInfo;
import com.yidiandao.business.ui.widget.listview.DisplayListItem;
import com.yidiandao.business.ui.widget.listview.viewholder.ShoppingCartOrderReduceHolder;

/** 购物车 订单 满减 活动 ListItem */
public class ShoppingCartOrderReduceListItem
        extends DisplayListItem<ShoppingCartOrderReduceHolder, FavourableInfo> {

    public ShoppingCartOrderReduceListItem(FavourableInfo favourableInfo) {
        super(favourableInfo);
    }

    @Override
    public void onShow(Context context, ShoppingCartOrderReduceHolder holder) {
        // 当前 满减活动属于订单
        // 显示标题
        holder.setTitle(data.getTitle());

        // 获取最优满减活动
        Discount bestDiscount = data.getBestDiscount();
        // 如果没有满减活动，说明未达条件，则直接显示默认即可
        if (bestDiscount == null) {
            // 没有达到减免活动的条件
            // 提示有满减活动
            holder.setContent(data.getContent());
        } else {
            // 如果有，则说明已达 满减活动条件，则设置为该满减活动的内容即可
            holder.setContent(bestDiscount.getSelectContent());
        }
    }

    @Override
    public String getDisplayItemTag() {
        return ShoppingCartOrderReduceListItem.class.getSimpleName();
    }

    @Override
    public Class<ShoppingCartOrderReduceHolder> getViewHolderClazz() {
        return ShoppingCartOrderReduceHolder.class;
    }
}
